package com.itheima.stargraph.utils;

import com.itheima.stargraph.pojo.User;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @Author mr.wu
 * @Data #{DATE} #{TIME}
 */
@Component
public class UserThreadlocalUtil {
    private static ThreadLocal<User> userThreadlocal =  new ThreadLocal<>();

    public static void setUser(User user){
        userThreadlocal.set(user);
    }

    public static User getUser(){
       return userThreadlocal.get();
    }

    public static void remove(){
        userThreadlocal.remove();
    }
}
